# data_loader.py

import json
import os

def load_evaluation_cache(cache_file='evaluation_cache.json'):
    """
    加载评估缓存数据。

    参数:
    - cache_file (str): 存储评估缓存的JSON文件路径。

    返回:
    - cache (dict): 键为超参数组合（JSON字符串），值为准确率。
    """
    if os.path.exists(cache_file):
        with open(cache_file, 'r') as f:
            cache = json.load(f)
        print(f"Loaded {len(cache)} hyperparameter configurations from {cache_file}.")
        return cache
    else:
        print(f"No evaluation cache found at {cache_file}.")
        return {}

def load_agent_paths(path_file='agent_paths.json'):
    """
    加载代理的移动路径数据。

    参数:
    - path_file (str): 存储代理路径的JSON文件路径。

    返回:
    - paths (list): 包含每个Episode路径的列表。
    """
    if os.path.exists(path_file):
        with open(path_file, 'r') as f:
            paths = json.load(f)
        print(f"Loaded {len(paths)} episodes from {path_file}.")
        return paths
    else:
        print(f"No agent paths found at {path_file}.")
        return []
